﻿-- =============================================
-- Author:		<赵洪涛>
-- Create date: <2012-04-19>
-- Description:	<转移成单>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Order_Shift] 
(
	@Order_Id varchar(200),
	@SalesmanAccount varchar(20),
	@Salesman nvarchar(50),
	@DeptId int
)
AS
BEGIN

Declare @cSql varchar(4000)

Set @cSql='Update a Set Salesman='''+@Salesman+''',SalesmanAccount='''+@SalesmanAccount+
	''',DepId='+Convert(varchar(20),@DeptId)+'
	From Order_Item a,(Select OId From [Order] Where Id In(' + @Order_Id + ')) b
	Where a.OId=b.OId'
Execute(@cSql)

Set @cSql='Update a Set Salesman='''+@Salesman+''',SalesmanAccount='''+@SalesmanAccount+
	''' From Project a,(Select OId From [Order] Where Id In(' + @Order_Id + ')) b
Where a.OrderId=b.OId'
Execute(@cSql)

Set @cSql='Update [Order] Set Salesman='''+@Salesman+''',SalesmanAccount='''+@SalesmanAccount+
	''',DepId='+Convert(varchar(20),@DeptId)+'
	Where Id In(' + @Order_Id + ')'
Execute(@cSql)

END